﻿<div>
<style type="text/css">
<!--
#adminContent ul ul {
	margin: 0 0 0 15px;
}

#adminContent ul li {
	margin: 5px 0 0 0;
}

-->
</style>
<h1>{lang:Permissions}</h1>
<form method="post">
{run: echo $menu->editForm($_menus, $userPermission);}
<input type="hidden" name="user_id" value="{user_id}" />
<br />
<input type="submit" value="{lang:Submit}" />
</form>
</div>

<script LANGUAGE="JavaScript"><!--

function chkClick(vel, ch) {
	var vParent = getParentOf(vel,'input');

	if(!ch||!vel.checked)
		getChildOf(vel,'input');


	if(!vParent)
		return false;
	var vParentParent = getParentOf(vel,'input');
	if(vParentParent) {
		var vHavChk = getParentOfChkV(vel,'li', true);
		if(!vHavChk) {
			vParentParent.checked = false;
		} else {
			vParentParent.checked = true;
		}
		chkClick(vParentParent, true);

	}
}



/*
 nn: nodeName
*/
function getParentOfChkV(el,nn, v) {
	var len = el.parentNode.parentNode.childNodes.length;
	nn = nn.toUpperCase();
	for(i=0; i<len; i++) {
		if(el.parentNode.parentNode.childNodes[i].nodeName.toUpperCase() == nn) {
			//return el.parentNode.childNodes[i];
			if( el.parentNode.parentNode.childNodes[i].childNodes[0].checked == v)
				return true;
		}
	}
	return false;
}


function getParentOf(el,nn) {
	var len = el.parentNode.parentNode.parentNode.childNodes.length;
	nn = nn.toUpperCase();
	for(i=0; i<len; i++) {
		if(el.parentNode.parentNode.parentNode.childNodes[i].nodeName.toUpperCase() == nn)
			return el.parentNode.parentNode.parentNode.childNodes[i];
	}
	return false;
}

/*
 nn: nodeName
*/
function getChildOf(el,nn) {
	var len = el.parentNode.lastChild.childNodes.length;
	if(!len)
		return false;
	var vel = el.parentNode.lastChild;
	var res = false;
	var j=0;

	nn = nn.toUpperCase();
	for(j=0; j<len; j++) {
		if(!vel.childNodes[j].firstChild)
			continue;
		if(vel.childNodes[j].firstChild.nodeName.toUpperCase() == nn) {
			vel.childNodes[j].firstChild.checked = el.checked;
			getChildOf(vel.childNodes[j].firstChild, nn, el.checked);
			res = true;
		}
	}
	return res;
}


//
--></script>
